<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>发布课题</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link rel="stylesheet" href="/css/teacher/publish.css"/>
    <script src="/wangeditor/wangEditor.min.js"></script>
</head>
<body>
<main class="main">
    <form id="contents">
        <input type="text" name="name" placeholder="课题名称" class="title" id="title"/>
        <div id="content" class="box"><h1 align="center">毕业设计课题内容和要求</h1>
            <ol>
                <li></li>
                <li></li>
            </ol>
        </div>
        <button class="submit" type="button">保存</button>
    </form>
</main>
</body>
<script src="/js/jquery.min.js"></script>
<script src="/js/config/server.js"></script>
<script src="/js/common/login.js"></script>
<script src="/layui/layui.all.js"></script>

<script>
  var E = window.wangEditor;
  var editor = new E('#content');
  editor.create();
  var topicId = sessionStorage.getItem('editId');
  if(topicId !== null){
    handlerGet('/rest/topic/get/'+topicId, 'teacher', function (data) {
      $("#title").val(data.data.name);
      $(".w-e-text").html(data.data.attention);
    })
  }
  $(".submit").on('click', function () {
    var title = $("#title").val();
    var attention = $(".w-e-text").html();

    var data = {
      topicId: topicId,
      name: title,
      attention: attention,
      teacherId: sessionStorage.getItem('teacherId')
    };
    console.log(title + "  | " + attention);
    console.log(JSON.stringify(data));
    handlerPost('/rest/topic/save', 'teacher', JSON.stringify(data), function (data) {
      layer.msg('保存成功,请继续编辑或准备提交审核')
    }, function () {
      layer.msg('请检查网络并重试')
    });
  });
</script>
</html>
